// 测试连接或截取

let arr1 = [ 2,4,6,8 ];
let arr2 = [ 1,3,5,7 ];

let arr3 = arr1.concat( arr2 );

console.log( arr1 );
console.log( arr2 );
console.log( arr3 );

console.log( arr3 == arr1 ); // false

let str = arr3.join( ':' ); // 将数组中各元素连接成字符串
console.log( str , typeof str );

console.log( '- - - '.repeat(10) );

let names = [ '温生民' , '王幸', '朱文杰' , '马冰月' , '王盼盼' ];
console.log( names );

let sub1 = names.slice( 3 );
console.log( sub1 );

let sub2 = names.slice( 0 , 3 );
console.log( sub2 );

let sub3 = names.slice( -2 );
console.log( sub3 );

let sub4 = names.slice( -2 , -1 );
console.log( sub4 );

console.log( '- - - '.repeat(10) );

let array = [ '唐三藏' , '孙悟空' , '白龙马' , '猪悟能' , '沙悟净' ];
console.log( array );

// Array.prototype.splice( start , deleteCount )
let deleted = array.splice( 0 , 1 );
console.log( `${deleted}被妖怪抓走了`);

console.log( array );

// Array.prototype.splice( start , deleteCount )
deleted = array.splice( 1 , 3 );
console.log( `${deleted}被妖怪抓走了`);

console.log( array );

let x = array.splice( 0 , 0 , '唐三藏' );
console.log( x );
console.log( array );

let y = array.splice( 2 , 0 , '白龙马' , '猪悟能' , '沙悟净' );
console.log( y );
console.log( array );